<template>
  <div class="newinfo-container">
    <h3 class="news-title">{{newsinfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间:{{newsinfo.add_time | dateformat}}</span>
      <span>点击{{newsinfo.click}}次</span>
    </p>
    <hr>
    <div class="newsinfo-content" v-html="newsinfo.content"></div>
    <cmt :id="id"></cmt>
  </div>
</template>
<script>
import {Toast} from 'mint-ui';
import Comment from '../subcomponents/Comment.vue'
export default {
  data() {
    return {
      id:this.$route.params.id,
      newsinfo:{}
    }
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo(){
      this.$http.get('api/getnew/'+this.id).then(result=>{
        // console.log(result.body);
        if(result.body.status === 0){
          this.newsinfo = result.body.message[0]
        } else{
          Toast("获取内容失败")
        }
      })
    }
  },
  components:{
    "cmt":Comment
  },

}
</script>
<style lang="scss">
  .newinfo-container {
    padding: 0 4px;
    .news-title{
      font-size: 16px;
      text-align: center;
      color: red;
      margin: 10px 0;
    }
    .subtitle{
      display: flex;
      justify-content: space-between;
      color: #226aff;
      span{
        display: block;
        font-size: 12px;

      }
    }
  }
</style>